package protocol.map;

import java.io.ByteArrayOutputStream;
import java.io.IOException;

import protocol.BasicProtocol;
import protocol.Iprotocol;
import util.ProtocolUtils;
import config.SystemDefine;

public class Map_protocol extends BasicProtocol implements Iprotocol {
	
	private int	roleId	= 0;
	
	private int	mapid	= 0;
	
	private int	x		= 0;
	
	private int	y		= 0;
	
	// /操作类型(用于模块系统内部的)
	private int	operate	= 0;
	
	public Map_protocol() {
		Type = SystemDefine.getInstance().getMapID();
	}
	
	@Override
	public byte[] write() {
		ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
		
		byte[] typeByteArr = ProtocolUtils.int2byteArray(Type);
		
		byte[] roleIdByteArr = ProtocolUtils.int2byteArray(roleId);
		byte[] mapidByteArr = ProtocolUtils.int2byteArray(mapid);
		byte[] operateByteArr = ProtocolUtils.int2byteArray(operate);
		
		byte[] xByteArr = ProtocolUtils.int2byteArray(x);
		byte[] yByteArr = ProtocolUtils.int2byteArray(y);
		
		
		enCodeFormat(outputStream, typeByteArr);
		enCodeFormat(outputStream, roleIdByteArr);
		enCodeFormat(outputStream, mapidByteArr);
		enCodeFormat(outputStream, operateByteArr);
		enCodeFormat(outputStream, xByteArr);
		enCodeFormat(outputStream, yByteArr);
		
		return outputStream.toByteArray();
	}
	
	@Override
	public void setType(int Type) {
		this.Type = Type;
	}
	
	@Override
	public int getType() {
		return this.Type;
	}
	
	public int getX() {
		return x;
	}
	
	public void setX(int x) {
		this.x = x;
	}
	
	public int getY() {
		return y;
	}
	
	public void setY(int y) {
		this.y = y;
	}
	
	public int getMapid() {
		return mapid;
	}
	
	public void setMapid(int mapid) {
		this.mapid = mapid;
	}
	
	public void setOperate(int ids) {
		operate = ids;
	}
	
	public void setRoleId(int roleId) {
		this.roleId = roleId;
	}
}
